package com.zhiming.item.cotroller;

import com.zhiming.item.pojo.Menu;
import com.zhiming.item.service.MenuService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 导航条 Controller
 */

@RestController
@Slf4j
public class MenuController {
    @Autowired
    private MenuService menuService;

    /**
     * 获取导航条菜单(一级菜单)
     */
    @GetMapping("/menu")
    public ResponseEntity<List<Menu>> findAll(){
        log.info("【获取导航条菜单(一级菜单)】");
        List<Menu> menuList = menuService.findMenuList();
        return ResponseEntity.ok(menuList);
    }

    /**
     * 根据导航id查询导航
     */
    @GetMapping("/menu/{id}")
    public ResponseEntity<Menu> findMenuById(@PathVariable("id") Integer id){
        log.info("【根据导航id查询导航】id="+ id);
        Menu menu = menuService.findMenuById(id);
        return ResponseEntity.ok(menu);
    }







}
